Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

fix(abigen): safe ident underscore followed by numeric #970

Merged
merged 1 commit into from
Feb 27, 2022

Conversation

mattsse
Copy link
Collaborator

@mattsse mattsse commented Feb 27, 2022

Motivation

Closes #967

Solution

check if identifiers are valid and prefix with an underscore if they start with a numeric value

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog


let provider = Arc::new(Provider::new(MockProvider::new()));
let contract = Test::new(Address::default(), Arc::clone(&provider));
// NOTE: this seems to be weird behaviour of `Inflector::to_snake_case` which turns "100pct" ->
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we fix this upstream? Is it right behavior?

@gakonst gakonst merged commit 960b873 into gakonst:master Feb 27, 2022
@gakonst
Copy link
Owner

gakonst commented Feb 27, 2022

Merged to unblock the compilation in the linked issue, but maybe we should fix inflector too?

@mattsse
Copy link
Collaborator Author

mattsse commented Feb 27, 2022

+1 on fixing this upstream, will look into the root cause.

let contract = Test::new(Address::default(), Arc::clone(&provider));
// NOTE: this seems to be weird behaviour of `Inflector::to_snake_case` which turns "100pct" ->
// "10_0pct"
let _call = contract._10_0pct("hello".to_string());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why it becomes 10_0pct and not 100_pct? @mattsse

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the comment right above this code line! It's an issue in the Inflector crate, which we'll track and solve separately

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abigen fails for identifier named _100pct
3 participants